package org.malred.hotelsystem.dao;

import android.annotation.SuppressLint;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class LoginDao {
    private static final String TAG = "LoginDao";

    /**
     * 登陆
     *
     * @param db
     * @param selectionArgs
     * @return
     */
    public static int login(SQLiteDatabase db, String... selectionArgs) {
        String where = "u_name=? and u_pass=? and u_role=?";

        // 表名|自定义查询列|查询条件|占位符的参数|分组|having|排序
        Cursor c = db.query("tb_user", null,
                where, selectionArgs, null, null, null);

        int res = 0;
        while (c.moveToNext()) {
            @SuppressLint("Range") String id = c.getString(c.getColumnIndex("u_id"));
            res++;
        }
        c.close();
        return res;
    }
}
